package main

import "fmt"

func send(out chan<- int) {
	out <- 89
	close(out)
}

func recv(in <-chan int) {
	n := <-in
	fmt.Println("n:=", n)
}

func main() {

	// ch := make(chan int)       //雙向channel
	// var sendCh chan<- int = ch //單向寫channel
	// sendCh <- 789

	// var revCh <-chan int = ch //單向讀channel
	// num := <-revCh
	// sendCh <- num
	// //fmt.Print("num", num)死鎖
	ch := make(chan int)
	go func() {
		send(ch)
	}()
	recv(ch)

}
